package com.macro.mall.common.util;

import java.util.Random;

/**
 * @Date 2024/8/7 9:06
 */
public class StringUtil {

    /**
     * 生成随机用户名，数字和字母组成
     *
     * @return
     */
    public static String getStringRandom() {
        String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            int index = random.nextInt(chars.length());
            char randomChar = chars.charAt(index);
            sb.append(randomChar);
        }
        return "user_" + sb;
    }

}
